<!DOCTYPE html>
<html lang="en">
<style>
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    input[type=checkbox], input[type=radio] {
        display: inline-block;
    }
</style>
<link href="/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<!-- 图片上传 -->
<!--引入CSS-->
<link rel="stylesheet" type="text/css" href="/static/webuploader/webuploader.css">
{include file="Public/head"}

<body data-type="widgets">
<!--<script src="/daterangepicker/jquery-3.2.1.min.js" type="text/javascript"></script>-->
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper" >
        <div class="row-content am-cf">
            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">修改</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>
                        <div class="widget-body am-fr">
                            <form id="roleform"  form="submit" class="am-form tpl-form-border-form tpl-form-border-br">
                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">文章标题 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" name="title" id="title" placeholder="请输入标题" value="{$data.title}">
                                        <small></small>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">文章类别 </label>
                                    <div class="col-sm-2">
                                        <select class="form-control" name="cat_id" id="cat_id">
                                            <option value="0">选择分类</option>
                                            {foreach name="category" key="key" item="v"}
                                            <option value="{$v.cat_id}" {if $data.cat_id eq $v.cat_id}selected="selected"{/if}>{$v.cat_name}</option>
                                            {/foreach}
                                        </select>
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">banner图 </label>
                                    <div class="am-u-sm-9">
                                        <input type="hidden" name="thumb" value="1" id="thumb">
                                        <input type="hidden" name="img" value="{$data.thumb}" id="img">
                                        <img src="{if $data.thumb}/upload/article/{$data.thumb} {else}/static/images/no_image.jpg{/if}" width="200" style="border:1pt solid #F6F6F6;">
                                        <div id="uploader1"  style="position: absolute;top:0px;left:220px;">
                                            <span id="filepicker1" class="btn">选择图片</span>
                                            <div class="uploader-list"></div>
                                        </div>
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">seo关键字 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" name="keywords"id="keywords" placeholder="请输入关键字" value="{$data.keywords}">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">外部链接 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" name="link"id="link" placeholder="请输入外部链接" value="{$data.link}">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">发布时间 </label>
                                    <div class="am-u-sm-9">
                                        <div class="input-prepend input-group">
                                    <span class="add-on input-group-addon">
                                            <i class="glyphicon glyphicon-calendar fa fa-calendar">
                                            </i>
                                    </span>
                                            <input type="text" class="form-control" id="publish_time" name="publish_time" value="{$data.publish_time|date="Y-m-d",###}">
                                        </div>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">是否显示 </label>
                                    <div class="am-u-sm-9">
                                        <label> <input type="radio" class="tpl-form-input" value="0" name="is_open" {if $data.is_open==0}checked="checked" {/if}>不显示</label>
                                        <label> <input type="radio" class="tpl-form-input" value="1" name="is_open" {if $data.is_open==1}checked="checked" {/if}>显示</label>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">网页描述 </label>
                                    <div class="am-u-sm-9">
                                        <textarea class="form-control" id="post_description" name="description" title="">{$data.description}</textarea>
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">文章内容 </label>
                                    <div class="am-u-sm-9">
                                        <script id="editor" type="text/plain" style="width:800px;height:500px;">{$data.content}</script>
                                        <small></small>
                                    </div>
                                </div>


                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <a onclick="javascript:history.back(-1);" ><div class="btn btn-default" type="reset" >返回</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>


                                        <button class="btn btn-info" type="button" onclick="master_add()">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
{include file='Public:validation'}
<!--图片引入JS-->
<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
<script type="text/javascript" src="/static/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="/static/js/uploader.js"></script>
<!--时间-->
<script src="/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<!--富文本-->
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
    //实例化编辑器
    var ue = UE.getEditor('editor');
    //获取内容
    function getContent(){
        arr=UE.getEditor('editor').getContent();
        return arr;
    }
    //时间插件
    $('#publish_time').daterangepicker({
        format:"YYYY-MM-DD",
        singleDatePicker: true,
        showDropdowns: true,
        minDate:'2016-01-01',
        maxDate:'2030-01-01',
        startDate:'2018-01-01',
        locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
    });

    //图片上传
    var uploader1;
    var arr1 = {
        'container':'#uploader1',
        'pick':'#filepicker1',
        'server':"{:url('webuploader')}",
        successHandler:function(file,response){
            var $input = $("input[name=thumb]");
            $input.val(response.filename);
            $input.siblings("img").attr("src",response.link);
        }
    };

    if(!uploader1){
        uploader1 = getUploader(arr1);
    }

    //提交
    function master_add(){
        var param = new Object();
        $("input").each(function(k, v){
            v = $(v);
            param[v.attr("id")] = v.val();
        });
        param['cat_id']= $("#cat_id option:selected").val();
        param['is_open']=$('input[name="is_open"]:checked').val();
        param['description']=$('#post_description').val();
        param['content']= getContent();//文本内容
        param['article_id']= {$data.article_id};
        $.post(
            "{:url('edit')}",
            param,
            function(ret){
                if(ret.code != 200){
                    layer.msg(ret.msg, {icon: 2});
                    return false;
                }
                layer.msg(ret.msg, {icon: 1,time:2000},function(){
                    location.href = "{:url('article_list')}";
                });
            });
    }


</script>

</html>